from javaproperties import Properties


class PropertiesUtils:
    _properties: Properties

    def __init__(self, property_file_path: str):
        self.properties = Properties()
        try:
            with open(property_file_path, "rb") as f:
                self.properties.load(f)
        except FileNotFoundError as e:
            raise FileNotFoundError(f"资源文件路径错误未找到{property_file_path}目录存在application.properties文件")

    def get_property_by_key(self, key: str) -> str:
        """

        :param key:属性的键名
        :return: 属性值
        """
        try:
            return self.properties[key]
        except KeyError as e:
            raise Exception(f"不存在属性{key}", e)


if __name__ == "__main__":
    pass